www.gusucode.com > 用matlab gui 实现界面互相切换功能 给你带来新的方法 创建不同类型的界面源码程序 > 用matlab gui 实现界面互相切换功能 给你带来新的方法 创建不同类型的界面源码程序/hittab.m
function hittab(action) % HITTAB - callback function to activate the tab switching % % HITTAB is part of the TAB-TOOL, consisting of two functions % DRAWTAB and HITTAB. These two functions allow the creation of tab % panels within Matlab. To build the "inside" of each tab you only % have to write one function for each tab panel and store all the % handles in the tab's userdata. % The tab insides are stored as the userdata of each tab. % % Dirk Tenne % CoDE (Control Dynamics and Estimation) % web: "http://code.eng.buffalo.edu" % created: "05/29/2002" % modified: "December 12. 2002" % switch action case 'start' set(gcbf,'WindowButtonMotionFcn','') set(gcbf,'WindowButtonUpFcn','hit_tab(''stop'')') case 'stop' tab = get(gco,'UserData'); % returns the handle of the tab all_child = get(tab,'UserData'); % gets all the children of % that tab tab_child = all_child.tab; inp_child = all_child.inp; matrix_child = all_child.matrix; ax_handle = get(gca,'Children'); % turn off the input fields for the current tab cur_tab = get(gca,'Userdata'); % current tab cur_chl = get(cur_tab,'Userdata'); % children of the current tab set(cur_chl.inp,'Visible','off') set(cur_chl.matrix,'Visible','off') set(inp_child,'Visible','on') set(matrix_child,'Visible','on') % changing the tab for i = 1:3 idx(i) = find(tab_child(i)==ax_handle); end ax_handle(idx) = ax_handle(1:3); ax_handle(1:3) = tab_child; set(gca,'Children',ax_handle) set(gca,'Userdata',tab) end